package com.karaoke.oksrv.controller

import com.karaoke.oksrv.domain.Repost
import com.karaoke.oksrv.domain.Stacktrace
import com.karaoke.oksrv.mapper.master.StacktraceMapper
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.bind.annotation.RestController

/**
 * Created by Administrator on 2017/3/7.
 */
@RestController
@RequestMapping("/api/report/")
class ReportController
{
    @Autowired
    lateinit var stacktraceMapper: StacktraceMapper

    @RequestMapping(value = "deviceReport", method = arrayOf(RequestMethod.POST))
    fun deviceReport(@RequestBody data: Repost)
    {
        val stack = Stacktrace().apply {
            ip = data.mCustomData?.ip
            cpuNo = data.mCustomData?.uuid
            roomNo = data.mCustomData?.roomNo
            reportId = data.mReportId
            stacktrace = data.mStacktrace
            userAppStartDate = data.mUserAppStartDate
            userCrashDate = data.mUserCrashDate
        }
        stacktraceMapper.insert(stack)
    }
}